# coding:utf-8
import sys
sys.path.append('D:/test/Appium2021')
from get_gata import GetData
from action_method import ActionMethod
from util.server import Server
class RunMain:
    def run_method(self):
        server =Server()
        server.main()
        data = GetData()
        action_method = ActionMethod()
        lines = data.get_case_lines()
        for i in range(1, lines):
            handle_step = data.get_handle_step(i) # 获取操作步骤如：send_key 第四列row3
            element_key = data.get_element_key(i) # 获取操作元素如：uesrname
            hadle_value = data.get_handle_value(i) # 获取操作元素的值 ：如123456
            expect_key = data.get_expect_element(i) # 获取预期元素
            expect_step = data.get_expct_handle(i) # 获取预期步骤

            excute_method = getattr(action_method, handle_step)

            if element_key != '':
                excute_method(element_key, hadle_value)
            else:
                excute_method(hadle_value)

            if expect_step != None:
                expect_result = getattr(action_method, expect_step)
                result = expect_result(expect_key)
                if result:
                    data.write_value(i, "passs")
                else:
                    data.write_value(i, "fail")





if __name__ == '__main__':
    run_method = RunMain()
    print(run_method.run_method())
